package com.tjec.project.projectWorkbench.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tjec.framework.aspectj.lang.annotation.Log;
import com.tjec.framework.aspectj.lang.enums.BusinessType;
import com.tjec.project.projectWorkbench.domain.BmsProjectLibrary;
import com.tjec.project.projectWorkbench.service.IBmsProjectLibraryService;
import com.tjec.framework.web.controller.BaseController;
import com.tjec.framework.web.domain.AjaxResult;
import com.tjec.common.utils.poi.ExcelUtil;
import com.tjec.framework.web.page.TableDataInfo;

/**
 * 精品项目库Controller
 * 
 * @author pangyongfeng
 * @date 2021-01-18
 */
@RestController
@RequestMapping("/projectWorkbench/projectLibrary")
public class BmsProjectLibraryController extends BaseController
{
    @Autowired
    private IBmsProjectLibraryService bmsProjectLibraryService;

    /**
     * 查询精品项目库列表
     */
    @PreAuthorize("@ss.hasPermi('projectWorkbench:projectLibrary:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmsProjectLibrary bmsProjectLibrary)
    {
        startPage();
        List<BmsProjectLibrary> list = bmsProjectLibraryService.selectBmsProjectLibraryList(bmsProjectLibrary);
        return getDataTable(list);
    }

    /**
     * 导出精品项目库列表
     */
    @PreAuthorize("@ss.hasPermi('projectWorkbench:projectLibrary:export')")
    @Log(title = "精品项目库", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BmsProjectLibrary bmsProjectLibrary)
    {
        List<BmsProjectLibrary> list = bmsProjectLibraryService.selectBmsProjectLibraryList(bmsProjectLibrary);
        ExcelUtil<BmsProjectLibrary> util = new ExcelUtil<BmsProjectLibrary>(BmsProjectLibrary.class);
        return util.exportExcel(list, "projectLibrary");
    }

    /**
     * 获取精品项目库详细信息
     */
   // @PreAuthorize("@ss.hasPermi('projectWorkbench:projectLibrary:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(bmsProjectLibraryService.selectBmsProjectLibraryByGuid(guid));
    }
    
    /**
     * 获取精品项目库详细信息
     */
    @GetMapping(value = "/getInfoByProjectId/{projectId}")
    public AjaxResult getInfoByProjectId(@PathVariable("projectId") String projectId)
    {
        return AjaxResult.success(bmsProjectLibraryService.selectBmsProjectLibraryByProjectId(projectId));
    }

    /**
     * 新增精品项目库
     */
    //@PreAuthorize("@ss.hasPermi('projectWorkbench:projectLibrary:add')")
    @Log(title = "精品项目库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmsProjectLibrary bmsProjectLibrary)
    {
        return toAjax(bmsProjectLibraryService.insertBmsProjectLibrary(bmsProjectLibrary));
    }

    /**
     * 修改精品项目库
     */
    //@PreAuthorize("@ss.hasPermi('projectWorkbench:projectLibrary:edit')")
    @Log(title = "精品项目库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmsProjectLibrary bmsProjectLibrary)
    {
        return toAjax(bmsProjectLibraryService.updateBmsProjectLibrary(bmsProjectLibrary));
    }

    /**
     * 删除精品项目库
     */
    @PreAuthorize("@ss.hasPermi('projectWorkbench:projectLibrary:remove')")
    @Log(title = "精品项目库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(bmsProjectLibraryService.deleteBmsProjectLibraryByGuids(guids));
    }
}
